package com.gjy.ds.sort_search;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-12-15 16:55:35
 */
public class SearchTest {

    private Search search;
    private static final Integer SIZE = 20;
    private int[] array = new int[SIZE];

    @BeforeEach
    public void before() {
        search = new Search();
        for (int i = 0; i < SIZE; i++) {
            array[i] = i;
        }
        System.out.println("原始数组: " + Arrays.toString(array));
    }

    @Test
    public void insert() {
        int seq = search.insert(array, 0, array.length - 1, 5);
        System.out.println("seq = " + seq);
    }

    @Test
    public void binary() {
        int seq = search.binary(array, 5);
        System.out.println("seq = " + seq);
    }

    @Test
    public void seq() {
        int seq = search.seq(array, 5);
        System.out.println("seq = " + seq);
    }

    @AfterEach
    public void after() {
        search = null;
        array = null;
    }
}
